#include "ExportPoint.h"
#include <direct.h>
#include <Windows.h>
#undef max
#undef min
//#include <Windows.h>

ExportPoint::ExportPoint(void):_fileName(NULL)
{
	if(_fileName) {free(_fileName); _fileName=NULL;}
}

void ExportPoint::setFileName(const char* fileName)
{
	/*SYSTEMTIME sysTime;
	GetLocalTime(&sysTime);
	sprintf(_fileName,"D:\\TrackingPoint\\%s%4d%02d%02d%02d%02d.txt",
	fileName,sysTime.wYear,sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute);*/
	_fileName =(char*)malloc( sizeof(char) * (strlen(fileName)+1) );
	if(!_fileName) {std::cout<<"need more memory!";return;}
	sprintf(_fileName,"%s",fileName);
	_in.open(_fileName,ios::in);
	if(_in){
		_in.close();
		remove(_fileName);
	}
}

void ExportPoint::write(int x,int y){

	_in.open(_fileName,ios::app);
	if (_in){
		_in<<x<<"  "<<y<<"\n";
		_in.close();
	//	printf("ExportPoint::Open file Error!");
	}
}

ExportPoint::~ExportPoint(void){
	if(_fileName) {free(_fileName); _fileName = NULL;}
}
